home *** CD-ROM | disk | FTP | other *** search
/ The PC-SIG Library 10 / The PC-Sig Library - Shareware for the IBM PC and Compatibles (PC-SIG)(Tenth Edition Disks 1-2804)(1991).iso / PC_SIGCD / 04 / 9 / DISK0491.ZIP / CRYPTAID.DOC < prev    next >
Text File  |  1986-03-18  |  13KB  |  266 lines

  1.  
  2.                   CRYPTANALYSIS HELPER
  3.                           by
  4.                      David Lovelock
  5.                  11632 E Fort Lowell Rd.,
  6.                     Tucson, AZ 85749.
  7.  
  8. I have a confession to make.  I know almost nothing about cryptanalysis.
  9. While teaching myself "C", I was looking for a project on which to exercise
  10. what I had learnt when my 13-year-old daughter received her latest copy of
  11. GAMES magazine with some messages that needed decoding.  This was a natural
  12. problem to tackle, but I am afraid I got a little carried away!  "C" is
  13. like that!
  14.  
  15. This copyrighted program is TAX-FREE WARE.  It is in the public domain in
  16. the sense that it may be distributed freely, without charge, by normal as
  17. well as BBS means.  However, if you find it useful, you are asked to send a
  18. $10 donation, which is TAX-DEDUCTIBLE, to
  19.  
  20. CCCC Search & Rescue Fund,
  21. P.O. Box 32548,
  22. Tucson,
  23. AZ 85751-2548
  24.  
  25. All funds will be used to buy computing equipment for Search and Rescue.
  26. None of this money goes to me or any other individual.  In fact, if you
  27. send money to me I will donate it to the fund.  A program which I wrote for
  28. the Commodore 64, called David's Directory Designer, has so far raised
  29. about $5000 for Search & Rescue computing equipment, under the TAX-FREE
  30. WARE concept.  Will MS-DOS users be as generous?
  31.  
  32. This program is designed to aid in the decoding of simple substitution
  33. aristocrat ciphers, i.e. each letter in the original message is replaced
  34. throughout by a unique cipher letter code, while punctuation and spaces are
  35. unchanged.  An excellent introduction to cryptanalysis in general and
  36. aristocrats in particular, can be found in CRYPTANALYSIS FOR MICROCOMPUTERS
  37. by Caxton C. Foster, (Hayden Book Co., 1982, Chapters 7 and 8, about $15).
  38. However, the programs mentioned there are not the ones presented here.
  39.  
  40. The programs supplied here are as follows:
  41.  
  42. CRYPTAID.DOC  - this file.
  43. CRYPTAID.EXE  - the main program - written in Microsoft's "C", Ver 3.00.
  44. 02.DCT   \
  45. 03.DCT    \   - A total of 17 *.DCT
  46. ...       /   - dictionary files.
  47. 18.DCT   /
  48. ADDTODCT.EXE  - file to append words to *.DCT files, with query.
  49. AUTOADD.EXE   - file to append words to *.DCT files, without query.
  50. SORTDCT.EXE   - sorts *.DCT files of up to 1,500 words.
  51. SORTALL.BAT   - a batch file which sorts all *.DCT files.
  52. SAMPLE.CIP    - a sample message that needs decoding.
  53.  
  54. They should all be on the same floppy, or all in the same sub-directory on a
  55. hard drive.  Obviously everything runs faster if a hard drive is available.
  56.  
  57. Before using the program CRYPTAID, enter the message to be decoded in a
  58. standard, unformatted, ASCII text file and  save it in the same directory
  59. as CRYPTAID and all its supporting programs.  Let's assume you have saved
  60. the file under the name "MESSAGE".  To invoke the deciphering aid, type
  61.  
  62. CRYPTAID MESSAGE
  63.  
  64. CRYPTAID will now load and display a title screen while it reads and
  65. analyses the file MESSAGE.  While reading, CRYPTAID does a number of
  66. things.
  67. It counts the number of occurrences of each letter of the alphabet in the
  68. entire text.
  69. It counts the number of occurrences of each letter of the alphabet which
  70. starts a word.
  71. It counts the number of occurrences of each letter of the alphabet which
  72. ends a word.
  73. It counts the number of occurrences of each letter of the alphabet as a
  74. single letter word.
  75. It does a consonant line analysis, suggesting which letters might be
  76. vowels, and which consonants.
  77. (If you want to try the program immediately, then a sample message has been
  78. included, called SAMPLE.CIP).
  79.  
  80. When it has read the entire text the main screen appears, divided into four
  81. sections.
  82.  
  83. The top section initially contains the upper case alphabet corresponding to
  84. the CIPHER text, with a blank line corresponding to the PLAIN text
  85. translation table below it.  Below that there is a lower case alphabet
  86. corresponding to the PLAIN text, followed by a blank line for the CIPHER
  87. code table.  When a guess is made these blank lines will automatically
  88. display the translation table.  Displaying the two way translation table is
  89. particularly useful if the code-maker has used a keyword as the basis of
  90. the cipher.  The convention adopted here, upper case for CIPHER text, and
  91. lower case for PLAIN text (the translation) is used throughout.
  92.  
  93. The second section displays up to six lines, 468 characters, of the file
  94. MESSAGE, in upper case.  Below each line is another line of characters,
  95. initially blank, which holds the translation of the letter directly above
  96. it.  It will be in lower case.  Word wrap is NOT in effect, so a word may
  97. be split between two lines.  You can tell checking for spaces at the
  98. borders.  Maybe, if there is demand, word wrap will be a future
  99. enhancement.  Maybe!
  100.  
  101. The third section gives the title of the cipher file and the choice of
  102. commands, while the fourth is the message area, which initially awaits you
  103. command.  The commands are activated by using the Function Keys (F1 - F10)
  104. and the SHIFTED function keys (S1 - S4).
  105.  
  106. Let's discuss these commands in order.
  107.  
  108. F1 IDEAS.  This will display a table of suggestions for the translation
  109. table.  If a cipher letter has already been translated, an asterisk (*)
  110. appears below it, and no suggestion is made.  If a letter from the plain
  111. text has been chosen it will be absent from the table.  This table is based
  112. entirely on the frequency count of total letters in the text.  According to
  113. the Brown Corpus (see Foster, page 257) the letter "E" occurs most
  114. frequently, and occurs 1250 times in every 10000 letters, i.e. it has a
  115. 12.5% frequency.  There is a table of frequency counts for all letters,
  116. with "Z" occurring the least (10 times in 10000, i.e. .1%).  All letters
  117. whose frequency in the cipher text are within 1% of the Brown Corpus
  118. frequency, are the ones suggested for translation when F1 is selected.
  119. Thus all letters in the cipher text which have a frequency count in the
  120. interval 11.5% - 13.5% would be suggested as an "E".  A letter with a
  121. frequency count greater than 13.5% would have no suggestion under it.
  122.  
  123. F2 TOTAL.  This is the frequency count of total letters in the cipher text.
  124. It displays the letters of the cipher text in alphabetical order together
  125. with the number of times the letter occurs in the text.  The number is also
  126. presented as a percentage of the total letters.
  127.  
  128. F3 ALL.  This is the same display as F2, but sorted in descending order of
  129. frequency.  The Brown Corpus frequency order of letters is also displayed
  130. alongside.  This therefore represents another set of suggestions.  However,
  131. if two or more letters of the cipher text have the same frequency count the
  132. order within that group is not significant, nor therefore is the specific
  133. suggestion.  Consequently the wise way to use this and subsequent tables is
  134. to look at all text letters in the vicinity of the suggested letter, rather
  135. than to treat the suggestion as absolute.
  136.  
  137. F4 FIRST.  This is similar to F3, except it is based on a frequency count
  138. of the first letters of each word.
  139.  
  140. F5 LAST.  This is similar to F3, except it is based on a frequency count of
  141. the last letters of each word.
  142.  
  143. F6 SINGLE.  This is similar to F3, except it is based on a frequency count
  144. of the one letter words.
  145.  
  146. F7 VOWELS.  This displays the result of the so-called consonant line
  147. analysis (Foster, pp 125 - 130), which offers suggestions for vowels and
  148. consonants.  An excellent way to build up a feeling for the interpretation
  149. and reliability of these (and other) suggestions is to get CRYPTAID to read
  150. in a plain text message which has not been coded in any way and see how
  151. good the correlation is!  An example at hand is this documentation file,
  152. CRYPTAID.DOC.
  153.  
  154. F8 DATA.  This displays a screen full of useful data: the most common two
  155. and three letter words and the frequency of the occurrences of successive
  156. vowels.  For example if a word contains successive vowels, the combination
  157. "AI" occurs 6.8% of the time compared to "IA"s 3.4%.
  158.  
  159. F9 MATCH.  As part of this package files named 02.DCT, 03.DCT, ..., and
  160. 18.DCT are included.  These are dictionaries (DCT) of two, three, ..., and
  161. eighteen letter words.  When you select F9, you are asked to type in the
  162. CIPHER text of the word you want to match.  The program works out the
  163. length of that word, goes to the appropriate dictionary, and starts
  164. searching through it for matches which are consistent with the pattern of
  165. the word, and any letters already selected.  If it finds a match, it
  166. displays the translation automatically on the screen.  If you want to
  167. accept the choice, type "a".  To reject and continue looking press the
  168. space-bar.  Any other key aborts the process.  This is a very useful aid. 
  169. Later I'll explain how you can enlarge and personalize these dictionaries.
  170.  
  171. F10 SELECT. (This is displayed as F0 on the screen).  This is the choice
  172. which allows you to select an individual letter's translation, and is the
  173. main feature of the package.  It will not allow you to select the same
  174. plain text letter for two different cipher text letters.  To deselect an
  175. incorrect choice, assign the space bar to the cipher letter you want to
  176. erase.
  177.  
  178. S1 QUIT.  Shifted F1 - ends the program immediately.
  179.  
  180. S2 CAESAR.  Shifted F2.  Perhaps the simplest aristocrat cipher is one in
  181. which the cipher alphabet is a simple block movement of the text alphabet.
  182. For example "a" might be "B", "b" would then be "C", and "z" would be "A". 
  183. This is called a Caesar.  S2 steps through, and displays, successive Caesar
  184. and reverse Caesar translations.
  185.  
  186. S3 CLEAR.  Shifted F3.  This immediately erases all you previous selections
  187. for the plain text.
  188.  
  189. S4 SAVE.  Shifted F4.  When you have solved the cipher, this will save the
  190. translated version of the first 6 lines of your cipher text, as an ASCII
  191. text file under the name SOLUTION.SLN.  Actually it will append the new
  192. message to any other message already there.  This is useful if you wish to
  193. update your dictionaries, explained below.
  194. There is no provision for reloading this saved text back into CRYPTAID.  If
  195. you are part way through deciphering a message and have to break, the
  196. easiest way to keep track of your place is to print the main screen to the
  197. printer (SHIFT Prt Sc).  Also if you want a hard copy of your entire
  198. solution, when completed, printing the screen gives it immediately.  Of
  199. course if you don't have a graphics printer the border will print an
  200. unusual sequence of letters!
  201.  
  202. CUSTOMIZING & ENLARGING THE DICTIONARIES.  There are three different ways
  203. to do this.
  204.  
  205. 1)  Count the number of letters in the word you want to add, and then load
  206. the appropriate dictionary into any standard text editor, and add the words
  207. you want.  (Words can be deleted in the same way.)  Make sure that each
  208. word is in UPPER-CASE, and on a line by itself.  They need not be in
  209. alphabetical order, although if you want to check whether your favorite
  210. word is there, it is easier if they are sorted!  A sort routine, described
  211. below, is supplied.  This technique is acceptable if you plan to add/delete
  212. a number of words all of the same length, but is inappropriate for
  213. multiple, different word length, additions.
  214.  
  215. 2)  Create your own text file, say EXTRAS.DOC, containing the words you
  216. want to add, again in upper-case, and each on a new line.  A good choice of
  217. words to add would be those contained in Foster, Appendix G.
  218.  
  219. If you are absolutely sure all the words in this file are to be added, run
  220. the program AUTOADD.EXE by typing
  221.  
  222. AUTOADD EXTRAS.DOC
  223.  
  224. This program will work out which dictionary the word should go in, and
  225. check whether it is already there.  If it is present, it goes on to the
  226. next word.  If it is absent it advises you and puts it at the end of the
  227. correct dictionary.
  228.  
  229. If you want to be queried every time a word is absent then in place of
  230. AUTOADD.EXE, you should run the program ADDTODCT.EXE by typing
  231.  
  232. ADDTODCT EXTRAS.DOC
  233.  
  234. On very large dictionaries with very large EXTRAS.DOC files, this process
  235. can be a little slow , but just leave it alone and have some coffee!
  236.  
  237. 3)  You can use the SOLUTION.SLN file in place of the EXTRAS.DOC example
  238. in 2) above.  In this way, the more you solve, the larger your dictionaries
  239. become.
  240.  
  241. A word of caution - DO NOT ADD WORDS WITH PUNCTUATION TO A DICTIONARY.  For
  242. example, words like I'LL should not be in any of the dictionaries.
  243.  
  244. SORTING DICTIONARIES.
  245. The program SORTDCT.EXE will sort any of the dictionaries provided they
  246. have less that 1500 words.  To sort the dictionary 05.DCT enter
  247.  
  248. SORTDCT 05
  249.  
  250. It will read 05.DCT into memory, advise you how many words there are, sort
  251. them (fairly quickly - a few seconds for 1500 words), save them in a file
  252. called 05.SRT, delete any files called 05.BAK, rename 05.DCT to 05.BAK, and
  253. then rename 05.SRT to 05.DCT.  It ends up by being pretty pleased with
  254. itself!
  255.  
  256. There is a batch file, called SORTALL.BAT which will sort all 17
  257. dictionaries if needed.
  258.  
  259. Finally, although this is designed to help solve aristocrats, it can also
  260. be used to create them.  Enter the plain text as though it were a cipher,
  261. and the encode it by selecting the translation, finally saving the encoded
  262. message in the SOLUTION.SLN file.  That is how I created SAMPLE.CIP.
  263.  
  264. I hope you have as much fun using this program as I did writing it!
  265.  
  266. March 18, 1986.  Tucson, AZ.